{include file="admin@public/header"/}

<link rel="stylesheet" href="/public/static/admin/css/report.css" />
<link rel="stylesheet" href="/public/static/admin/easyui/layui-v2.6.8/css/layui.css">

<style>
	.ui-icon-ellipsis {
		right: 5px;
	}

	#filter-menu .con {
		width: 355px;
	}

	#filter-menu label.tit {
		width: 80px;
	}

	/*.ui-jqgrid tr.jqgrow td {
	white-space: normal !important;
	}
	*/
	.no-query {
		background: url("/public/static/admin/css/img/no_query.png") no-repeat scroll 100px 60px #fff;
		background-position: center;
		border: 1px solid #ddd;
		border-top: none;
		height: 402px;
		margin-right: 0;
	}

	.box-flex {
		overflow: hidden;
		zoom: 1;
	}

	.box-flex .flex {
		float: left;
		width: 33.3%;
	}

	.grid-title {
		font-size: 24px;
		text-align: center;
		clear: none;
	}

	.ui-print .grid-wrap {
		padding: 10px 0 0 30px;
	}

	#conditions-trigger {
		background: url(/public/static/admin/css/img/bg.png) no-repeat;
		border: 0px;
		width: 74px;
		box-shadow: 0px 0px;
	}

	#filter-menu .conditions-trigger>b {
		position: absolute;
		right: 0;
		top: 50%;
		margin-top: -8px;
		width: 16px;
		height: 16px;
		background: url(/public/static/admin/css/img/down.png) 2px 5px no-repeat;
	}

	#filter-menu .conditions-trigger>b.act {
		background: url(/public/static/admin/css/img/up.png) 2px 5px no-repeat;
	}

	#filter-menu .btns {
		position: absolute;
		top: 7px;
		right: 0px;
	}

	.layui-form-checkbox[lay-skin=primary] i {
		padding: 0;
	}

	.layui-form-checked[lay-skin=primary] i {
		border-color: #5dc5e7;
		background-color: #5dc5e7;
		color: #fff;
		padding: 0;
	}

	.layui-form-checkbox[lay-skin=primary]:hover i {
		border-color: #5dc5e7;
	}

	.ui-droplist-wrap {
		height: auto;
	}

	#filterItems {
		height: auto;
	}

	.ui-droplist-wrap .list-item:hover {
		background-color: #faffad;
	}

	.ui-print .ui-jqgrid .ui-jqgrid-hdiv,
	.ui-print .ui-jqgrid .ui-jqgrid-htable th {
		background: url(/public/static/admin/youshang/css/img/ui-th.png) repeat-x #EEE;
	}
</style>

<div class="bill-ser-top">
	<ul class="ul-inline cf" style="font-size: 12px;">
		<li>
			<input type="text" id="matchCon" class="ui-input ui-input-ph con" value="" placeholder="请输入单据号或备注"
				style="width: 200px;">
		</li>
		<li>
			<label>单据日期:</label>
			<input type="date" id="startdate" value="2021-08-24" class="ui-input " style="width: 120px;">
			<span>-</span>
			<input type="date" id="enddate" value="2021-08-30" class="ui-input " style="width: 120px;">
		</li>
		<li id="store" style="display: list-item;">
			<label>审核状态:</label>
			<span id="storage">
				<span class="ui-combo-wrap ui-combo-active" style="width: 118px;">
					<input type="text" class="input-txt" autocomplete="off" readonly="readonly"
						style="cursor: default; width: 92px;" value="(空)" id="storageTitle">
					<span class="trigger"></span>
				</span>
			</span>
		</li>
		<li><a class="mrb more ui-btn" id="moreCon">高级搜索</a><a class="mrb ui-btn ui-btn-search" id="search">查询</a></li>
	</ul>

	<!-- 选择审核状态 -->
	<div class="ui-droplist-wrap" id="storageBox"
		style="position: absolute; top: 44px; z-index: 1000; width: 118px; display: none; left: 180.688px;">
		<div class="droplist" style="position: relative; overflow: auto; min-height: 150px; height: 150px;">
			<div class="list-item selected" data-value="-1" title="(空)">(空)</div>
			<div class="list-item" data-value="1291309293115060" title="未审核">未审核</div>
			<div class="list-item" data-value="1291309295033835" title="已审核">已审核</div>
		</div>
	</div>

</div>

<div class="wrapper btc" style="padding: 15px 15px;box-sizing: border-box;">
	<div class="bill-ser-botm">
		<div class="cf">
			<div class="ui-config-box">
				<span id="config" class="ui-config"><a href="#" class="ui-icon-config-new"></a>列设置</span>
			</div>
			<div class="fr">
				<a class="ui-btn-bill ui-btn-add" id="add"
					onclick="addPage('/store/assembly/add.html','storage','组装单')">新增</a>
				<div class="ui-btn-menu ml10">
					<a class="ui-btn-bill ui-btn-hl menu-btn mrb" style="width: 40px;padding-right: 14px;" href="#"
						id="audit">审核<b></b></a>
					<div class="con hl more-operate-con"
						style="margin-left: 0px;font-size: 14px;width: 55px;padding: 6px;">
						<ul class="more-operate cf" style="border-style:dashed; border-width:1px; border-color:#ccc;">
							<li><a href="#" id="reAudit">反审核</a></li>
						</ul>
					</div>
				</div>
				<div class="ui-btn-menu ml10">
					<a class="ui-btn-bill ui-btn-hl menu-btn mrb" href="#" id="print" target="_blank"
						href="javascript:void(0);">打印<b></b></a>
					<div class="con hl more-operate-con"
						style="margin-left: 0px;font-size: 14px;width: 54px;padding: 3px;">
						<ul class="more-operate cf" style="border-style:dashed; border-width:1px; border-color:#ccc;">
							<li style="padding-left: 8px;"><a href="#" id="printSet" href="javascript:void(0);">设置</a>
							</li>
						</ul>
					</div>
				</div>
				<a class="ui-btn-bill ui-btn-hl ml10" id="export" href="javascript:void(0);">导出</a>
				<a href="#" class="ui-btn-bill ui-btn-hl ml10" id="btn-batchDel">删除</a>
			</div>
		</div>
	</div>
	<div class="grid-wrap">
		<table id="grid">
		</table>
		<div id="page"></div>
	</div>
</div>

<script type="text/javascript" src="/public/static/admin/easyui/jeasyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
	function preview(oper) {
		if (oper < 10) {
			$("#grid-wrap").jqprint();
		} else {
			window.print();
		}
	}

</script>


<script type="text/javascript">

	$(document).ready(function () {

		// 点击查询按钮
		$("#filter-submit").click(function () {
			$("#ui-print").css({ "visibility": "visible" });  //显示表格数据
			$(".no-query").hide();  //隐藏提示


			var startdate = $('#startdate').val();
			var enddate = $('#enddate').val();


			//此处可以添加对查询数据的合法验证 
			$("#grid").jqGrid('setGridParam', {
				datatype: 'json',
				postData: { 'ajax': '100' }, //发送数据 
				page: 1
			}).trigger("reloadGrid"); //重新载入 
		});



		//alert("1111");
		$("#grid").jqGrid({
			url: '/store/assembly/index.html?ajax=100',
			datatype: "json",//数据来源，本地数据（local，json,jsonp,xml等）
			height: '90%',//高度，表格高度。可为数值、百分比或'auto'
			colNames: ["id", "操作", "单据日期", "单据编号", "组合件", "组合件数量", "单位", "组装费用", "组合件单位成本", "组合件成本", "子件", "子件数量", "单位", "子件单位成本", "子件成本", "制单人", "审核人", "审核日期", "备注", "打印次数"],
			colModel: [
				{ name: 'id', width: 60, label: "id", hidden: true },
				{ name: '', index: 'id', width: 60, label: "操作", formatter: cLink },
				{ name: 'addtime', width: 80, label: "单据日期" },
				{ name: 'sn', width: 120, label: "单据编号" },
				{ name: 'goods_name', width: 200, label: "组合件" },
				{ name: 'number', width: 80, label: "组合件数量" },
				{ name: 'unit_name', width: 35, label: "单位" },
				{ name: 'money', width: 80, label: "组装费用" },
				{ name: '', width: 100, label: "组合件单位成本" },
				{ name: '', width: 80, label: "组合件成本" },
				{ name: '', width: 200, label: "子件", formatter: child },
				{ name: '', width: 80, label: "子件数量", formatter: childNum },
				{ name: '', width: 35, label: "单位", formatter: childUnit },
				{ name: '', width: 100, label: "子件单位成本", formatter: childdwcb },
				{ name: '', width: 80, label: "子件成本", formatter: childcb },
				{ name: 'by', width: 80, label: "制单人" },
				{ name: 'check_status', width: 80, label: "审核人" },
				{ name: 'check_time', width: 80, label: "审核日期" },
				{ name: 'mark', width: 200, label: "备注" },
				{ name: 'print_num', width: 100, label: "打印次数" },

			],
			cellEdit: true,
			cellurl: '/',
			sortable: true,  //排序

			rowNum: 100,
			rowList: [100, 200, 500],
			sortname: 'id',
			sortorder: "desc",
			pagerpos: "left",//分页位置

			pgbuttons: true,//翻页按钮
			rownumbers: true, //自增序号
			pagination: true,
			altRows: !0,
			gridview: !0,
			shrinkToFit: !1,
			cellLayout: 8,
			autowidth: !0,
			pager: "#page",
			viewrecords: !0,
			cmTemplate: {
				sortable: !1,
				title: !1
			},
			loadError: function (t, e, i) {
				parent.Public.tips({
					type: 1,
					content: "操作失败了哦，请检查您的网络链接！"
				})
			},
			//双击表格行事件
			ondblClickRow: function (row) {
				var rowData = $('#grid').jqGrid('getRowData', row);
				parent.tab.addTabItem({
					tabid: "storage",
					text: "组装单",
					url: "/store/assembly/edit.html?id=" + rowData.id,
				})
			}
		});

	});
	// 操作按钮
	function cLink(cellvalue, options, rowObject) {
		return '<div class="operating"><span class="ui-icon ui-icon-pencil" onclick="" title="修改"></span><span class="ui-icon ui-icon-trash" onclick="del(' + rowObject.id + ')" title="删除"></span></div>'
	}

	// 子件
	function child(cellvalue, options, rowObject) {
		var html = '<div>';
		for (let i = 0; i < rowObject.son.length; i++) {
			const element = rowObject.son[i];
			html += '<p class="line combineOrNot"></p><p class="combineOrNot combineHeight pl25">' + element.goods_name + '</p>';
		}
		html += '</div >';
		return html;
	}

	// 子件数量
	function childNum(cellvalue, options, rowObject) {
		var html = '<div>';
		for (let i = 0; i < rowObject.son.length; i++) {
			const element = rowObject.son[i];
			html += '<p class="line combineOrNot"></p><p class="combineOrNot combineHeight pl25">' + element.number + '</p>';
		}
		html += '</div >';
		return html;
	}

	// 子件单位
	function childUnit(cellvalue, options, rowObject) {
		var html = '<div>';
		for (let i = 0; i < rowObject.son.length; i++) {
			const element = rowObject.son[i];
			html += '<p class="line combineOrNot"></p><p class="combineOrNot combineHeight pl25">' + element.unit_name + '</p>';
		}
		html += '</div >';
		return html;
	}

	// 子件单位成本
	function childdwcb(cellvalue, options, rowObject) {
		var html = '<div>';
		for (let i = 0; i < rowObject.son.length; i++) {
			const element = rowObject.son[i];
			html += '<p class="line combineOrNot"></p><p class="combineOrNot combineHeight pl25">' + element.dwcb + '</p>';
		}
		html += '</div >';
		return html;
	}

	// 子件成本
	function childcb(cellvalue, options, rowObject) {
		var html = '<div>';
		for (let i = 0; i < rowObject.son.length; i++) {
			const element = rowObject.son[i];
			html += '<p class="line combineOrNot"></p><p class="combineOrNot combineHeight pl25">' + element.cb + '</p>';
		}
		html += '</div >';
		return html;
	}

</script>

<script type="text/javascript">
	$(document).ready(function () {
		// 获取当前日期
		var myDate = new Date;
		var year = myDate.getFullYear(); //获取当前年
		var mon = myDate.getMonth() + 1; //获取当前月
		var date = myDate.getDate(); //获取当前日
		// console.log(year + '-' + mon + '-' + date)
		if (mon < 10) {
			mon = "0" + mon;
		}
		if (date < 10) {
			date = "0" + date;
		}
		$("#startdate").val(year + '-' + mon + '-01');
		$("#enddate").val(year + '-' + mon + '-' + date);


		//顶部搜索是否展开（1：展开，0：未展开）
		var headH = 0;
		$("#conditions-trigger").click(function () {
			if (headH == 0) {
				headH = 1;
				$("#filterItems").css({ "height": "auto" });
				$(this).html("&nbsp;收起条件<b class='act'></b>");
			} else {
				headH = 0;
				$("#filterItems").css({ "height": "44px" });
				// $("#filterItems").animate({height:'44px'});
				$(this).html("&nbsp;更多条件<b></b>");
			}
		});

		// 搜索审核状态弹窗
		$("#storage").on("click", function () {
			var top = $(this).offset().top;
			var left = $(this).offset().left;
			var width = $(this).width();
			$("#storageBox").toggle();
			$("#storageBox").css({ "top": (top + 24) + "px", "left": (left) + "px", "minWidth": width + "px" });
		});
		// 审核状态选择审核状态
		$("#storageBox .list-item").on("click", function () {
			$(this).addClass("selected").siblings().removeClass("selected");
			var title = $(this).attr("title");
			var val = $(this).attr("data-value");
			$("#storageTitle").val(title);
			$("#storageBox").hide();
		});


		//选择框外点击则隐藏
		$(document).mouseup(function (e) {
			if (e.target.id != "storage") {
				var con = $("#storageBox");   // 设置目标区域
				if (!con.is(e.target) && con.has(e.target).length === 0) {
					$("#storageBox").hide();
				}
			}
		});



	});

</script>

{include file="admin@public/footer"/}